<template>
  <div class="m-one">
    <div class='one' @click="increment" >
      Count_Two {{ count }}
      <input type='button' @click="increment(2)" value="加2" /> 
      </div>
  </div>
</template>

<script>
import store from "../store";
import { mapMutations } from 'vuex'
export default {
  name: "two",
  methods: {
    // increment(num) {
    //   //this.$store.state.count+=1;
    //   this.$store.commit('increment',num)
    // },

    ...mapMutations({
      increment:'increment'
    })
  },
  computed: {
    count() {
      return this.$store.state.count;
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.m-one {
  width: 100%;
  height: 100px;
  line-height: 100px;
  text-align: center;
  background-color: lightblue;
}
</style>
